print(1## 构造任务1-项目初始化

###任务1：生成50个随机的加减法的算式

代码参考

创建空项目：CalculatorProjectXXX

创建模块1：Calcu_01_demo_xxx

注意：XXX为拼音缩写

创建MainTest类

实现50个随机的加减法的算式生成。

```java
import random


def add_test(sum_value, count, column_count=0):
    questions = ''
    count_temp = 0

    while True:
        calc_type = random.randrange(0, 1)
        i = random.randrange(1, sum_value)
        j = random.randrange(2, sum_value + 1)
        l = j - i
        if l > 0:
            str_temp = str(i) + ' + ' + str(l) + '' + ' =    \n'
            questions += str_temp
            count_temp += 1
        elif (l < 0):
            str_temp = str(i) + ' - ' + str(abs(l)) + '' + ' =    \n'
            questions += str_temp
            count_temp += 1
            print(str_temp)
        else:
            if (random.randrange(0, 1)):
                str_temp = str(i) + ' - ' + str(l) + '' + ' =    \n'
            else:
                str_temp = str(i) + ' + ' + str(l) + '' + ' =    \n'
            questions += str_temp
            count_temp += 1
        if count_temp >= count:
            break
    return questions


def main():
    sum_value, count = 100, 50
    q = add_test(sum_value, count)
    str_title = '%d以内加减法算术题%d题.doc' % (sum_value, count)
    with open(str_title, "w") as f:
        f.write(q)
    f.close()


if __name__ == '__main__':
    main()
```

运行效果截图如下：


###任务2：实现算式结果0-100之间

代码如下：

```java

import random


def add_test(sum_value, count, column_count=0):
    questions = ''
    count_temp = 0

    while True:
        calc_type = random.randrange(0, 1)
        i = random.randrange(1, sum_value)
        j = random.randrange(2, sum_value + 1)
        l = j - i
        if l > 0:
            str_temp = str(i) + ' + ' + str(l) + '' + ' =    \n'
            questions += str_temp
            count_temp += 1
        elif (l < 0):
            str_temp = str(i) + ' - ' + str(abs(l)) + '' + ' =    \n'
            questions += str_temp
            count_temp += 1
            print(str_temp)
        else:
            if (random.randrange(0, 1)):
                str_temp = str(i) + ' - ' + str(l) + '' + ' =    \n'
            else:
                str_temp = str(i) + ' + ' + str(l) + '' + ' =    \n'
            questions += str_temp
            count_temp += 1
        if count_temp >= count:
            break
    return questions


def main():
    sum_value, count = 100, 50
    q = add_test(sum_value, count)
    str_title = '%d以内加减法算术题%d题.doc' % (sum_value, count)
    with open(str_title, "w") as f:
        f.write(q)
    f.close()


if __name__ == '__main__':
    main()
```

运行效果截图如下：


### 任务3：实现算式参考答案功能

代码如下：

```java


```



运行效果截图如下：)